<?php include_once '../include/header.php' ?>
<?php include_once '../../usercontroller.php' ?>
<div id="panelNav">
    <div id="logo-featured"><img src="../../Images/icon_dashboard_user.png" alt=""/><span>Sửa thông tin thành viên</span></div>
    <ul>
        <li><a href="#"><img src="../../Images/icon_cancel.png" class="qTip cancel" onclick="window.location='index.php'"  title="Đóng lại" border="0"/></a> </li>
        <li><a href="#"><img src="../../Images/icon_save_new.png" class="qTip save_new"  title="Lưu lại" border="0" onclick="submit();" /></a> </li>
        <!--li><a href="#"><img src="../../Images/icon_save_close.png" class="qTip save_close"  title="Lưu và đóng lại" border="0"/></a> </li>
        <li><a href="#"><img src="../../Images/icon_apply.png" class="qTip apply" onclick="return checkvalidate()" title="Apply dữ liệu" border="0"/></a> </li-->
    </ul>
</div><!--end #menu_news-->
<div class="ui-corner-all" style="display:none;height:30px;line-height: 30px;margin-top: 20px; padding: 0 .7em;">
    <p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;margin-top:.7em;"></span>
        <strong></strong></p>
</div>
<div id="content" style="height: auto">
    <div id="main-container" style="height: auto">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <div id="tabs1">
            <ul>
                <li><a href="#tabs-1">Thông tin tài khoản</a></li>                
            </ul>
            <div id="tabs-1" style="position: relative">
                <form id="create" action="" method="POST" enctype="multipart/form-data">
                    <input type="hidden" name="checkUpdate" id="checkUpdate" value="update" />
                    <fieldset class="create-form">
                        <legend>Thông tin thành viên</legend>
                        <table cellpadding="8" cellspacing="8">
                            <tr>
                                <td>Mã sinh viên:<span style="color:#f00">*</span> </td>
                                <td><input type="text" class="text-input" id="masv" name="masv" value="<?php echo $member[1] ?>" size="30" />
                                    <div id="UsernameExist" class="ssss" ></div>
                                </td>
                            </tr>
                            <tr>
                                <td>Tên tài khoản<span style="color:#f00">*</span> </td>
                                <td><input type="text" class="text-input" id="taikhoan" name="taikhoan" value="<?php echo $member[2] ?>" size="30" />
                                    <div id="UsernameExist" class="ssss" ></div>
                                </td>
                            </tr>
                            <tr>
                                <td>Mật khẩu<span style="color:#f00">*</span> </td>
                                <td><input type="password" class="text-input" id="matkhau" name="matkhau" value="" size="30"/></td>
                            </tr>
                            <tr>
                                <td>Nhập lại mật khẩu<span style="color:#f00">*</span> </td>
                                <td><input type="password" class="text-input" id="matkhau2" name="matkhau2" value="" size="30"/><div id="passs" class="ssss"></div></td>
                            </tr>
                            <tr>
                                <td>Họ và tên<span style="color:#f00">*</span> </td>
                                <td><input type="text" class="validate text-input" id="fullname" name="fullname" value="<?php echo $member[4] ?>" size="30"/></td>
                            </tr>
                            <tr>
                                <td>Ngày sinh<span style="color:#f00">*</span> </td>
                                <td><input type="text" class="validate text-input" id="ngaysinh" name="ngaysinh" value="<?php echo $member[5] ?>" size="30"/></td>
                            </tr>
                            <tr>
                                <td>Giới tính<span style="color:#f00">*</span> </td>
                                <td>                                    
                                    <input <?php if ($member[6] == "Nam") {
    echo "checked = 'checked'";
} ?> name="gioitinh" value="Nam" type="radio" checked />Nam <input <?php if ($member[6] == "Nữ") {
    echo "checked = 'checked'";
} ?> name="gioitinh" value="Nữ" type="radio" />Nữ </td>
                            </tr>
                            <tr>
                                <td>Quê quán<span style="color:#f00">*</span> </td>
                                <td><input type="text" class="validate text-input" id="quequan" name="quequan" value="<?php echo $member[7] ?>" size="50"/></td>
                            </tr>
                            <tr>
                                <td>Địa chỉ hiện tại<span style="color:#f00">*</span> </td>
                                <td><input type="text" class="validate text-input" id="diachi" name="diachi" value="<?php echo $member[8] ?>" size="50"/></td>
                            </tr>
                            <tr>
                                <td>Email<span style="color:#f00">*</span> </td>
                                <td><input type="text" class="validate text-input" id="email" name="email" value="<?php echo $member[9] ?>" size="30"/></td>
                            </tr>                   
                            <tr>
                                <td>Số điện thoại<span style="color:#f00">*</span> </td>
                                <td><input type="text" class="validate text-input" id="sodienthoai" name="sodienthoai" value="<?php echo $member[10] ?>" size="30"/></td>                            
                            </tr>
                            <tr>
                                <td>Nghề nghiệp:<span style="color:#f00">*</span> </td>
                                <td><input type="text" class="validate text-input" id="nghenghiep" name="nghenghiep" value="<?php echo $member[17] ?>" size="30"/></td>                            
                            </tr>
                            <tr>
                                <td>Tài khoản Yahoo!<span style="color:#f00"></span> </td>
                                <td><input type="text" class=" text-input" id="yahoo" name="yahoo" value="<?php echo $member[11] ?>" size="30"/></td>
                            </tr>
                            <tr>
                                <td>Tài khoản Skype<span style="color:#f00"></span> </td>
                                <td><input type="text" class=" text-input" id="skype" name="skype" value="<?php echo $member[12] ?>" size="30"/></td>
                            </tr>
                            <tr>
                                <td>Tài khoản Facebook<span style="color:#f00"></span> </td>
                                <td><input type="text" class=" text-input" id="facebook" name="facebook" value="<?php echo $member[13] ?>" size="30"/></td>
                            </tr>

                            <tr>
                                <td>Avatar <span style="color:#f00">*</span></td>
                                <td>
                                    <input type="file" id="avatar" name="avatar" value="" size="30"/>
                                    <input type="hidden" name="getavatar" value="<?php echo $member[15] ?>"/>
                                </td>
                            </tr>                    
                            <tr>
                                <td>Trạng thái <span style="color:#f00">*</span></td>
                                <td><select name="status" class="validate" id="delete_status">
<?php if ($member[16] == 1) { ?>
                                            <option selected value="1">Kích hoạt</option>
                                            <option value="0">Bỏ Kích hoạt</option>
<?php } else if ($member[16] == 0) { ?>
                                            <option  value="1">Kích hoạt</option>
                                            <option selected value="0">Bỏ Kích hoạt</option>
<?php } ?>
                                    </select>
                                </td>
                            </tr>
                        </table>
                        <div style="margin: 5px;">
                            Miêu tả bản thân <span style="color:#f00">*</span><textarea cols="" rows=""  id="description" name="description" style="height:300px;width:800px;overflow: scroll;font-size:11px; "><?php echo $member[14] ?></textarea>
                        </div>
                       
                    </fieldset>                     
                </form>        
                <div style="position: absolute;top:350px;left:400px;z-index: 9999999">
                    <img  width="65px" height="65px" class="img-border" src="../../data/avatar/<?php echo $member[15] ?>" alt="<?php echo $member[14] ?>"/>
                </div>
            </div>
        </div>
    </div>
    <style>
        .ssss{
            display: none;
            position: relative;
            top: 5px;
        }
    </style>
    <script type="text/javascript">
        (function($)
        {
            $('#description').wysiwyg({
                controls: {
                    strikeThrough : { visible : true },
                    underline     : { visible : true },

                    separator00 : { visible : true },

                    justifyLeft   : { visible : true },
                    justifyCenter : { visible : true },
                    justifyRight  : { visible : true },
                    justifyFull   : { visible : true },

                    separator01 : { visible : true },

                    indent  : { visible : true },
                    outdent : { visible : true },

                    separator02 : { visible : true },

                    subscript   : { visible : true },
                    superscript : { visible : true },

                    separator03 : { visible : true },

                    undo : { visible : true },
                    redo : { visible : true },

                    separator04 : { visible : true },

                    insertOrderedList    : { visible : true },
                    insertUnorderedList  : { visible : true },
                    insertHorizontalRule : { visible : true },

                    h4mozilla : { visible : true && $.browser.mozilla, className : 'h4', command : 'heading', arguments : ['h4'], tags : ['h4'], tooltip : "Header 4" },
                    h5mozilla : { visible : true && $.browser.mozilla, className : 'h5', command : 'heading', arguments : ['h5'], tags : ['h5'], tooltip : "Header 5" },
                    h6mozilla : { visible : true && $.browser.mozilla, className : 'h6', command : 'heading', arguments : ['h6'], tags : ['h6'], tooltip : "Header 6" },

                    h4 : { visible : true && !( $.browser.mozilla ), className : 'h4', command : 'formatBlock', arguments : ['<H4>'], tags : ['h4'], tooltip : "Header 4" },
                    h5 : { visible : true && !( $.browser.mozilla ), className : 'h5', command : 'formatBlock', arguments : ['<H5>'], tags : ['h5'], tooltip : "Header 5" },
                    h6 : { visible : true && !( $.browser.mozilla ), className : 'h6', command : 'formatBlock', arguments : ['<H6>'], tags : ['h6'], tooltip : "Header 6" },

                    separator07 : { visible : true },

                    cut   : { visible : true },
                    copy  : { visible : true },
                    paste : { visible : true }    
                }
            });
        })(jQuery);
        $("#tabs1").tabs();
        $('#ngaysinh').datepicker();
        $('#taikhoan').keyup(function(){
            var name=$(this).val();
            if(name.length<4){
                $('#UsernameExist').html("<img src='../../Images/icon_alert.png' valign='midle' /> ").css("display","inline");
            } else{
                $.post("../../controllers/thanhviencontroller.php?action=checkName&name="+name,null,function(data){
                    if(data==true){
                        $('div#UsernameExist').html("<img src='../../Images/icon_active.png' height='18' valign='midle' /> ").css("display","inline");
                        $(this).focus().css("border", "1px solid #f00");
                    }
                    else{
                        $(this).css("border","1px solid #cecece");
                        $('div#UsernameExist').html("<img src='../../Images/icon_alert.png' height='18' valign='midle' /> ").css("display","inline");
                    }
                });
            }
         
        });
        $('#matkhau2').change(function(){
            var txt=$(this).val();
            var txt1=$('#matkhau').val();
            if(txt!=txt1||txt1.length<6){
                $(".ui-corner-all").addClass("ui-state-error");
                $(".ui-corner-all p strong").html("Mật khẩu quá ngắn hoặc không khớp !");
                $(".ui-corner-all").fadeTo("slow", 1);
                setTimeout("$('.ui-corner-all').slideUp('slow');","2000");
                $('#matkhau').val("").focus().css("border","1px solid #f00");
                $('#matkhau2').val("").css("border","1px solid #f00");
                $('#passs').html("");
            }else{
                $('#matkhau').css("border","1px solid #cecece");
                $('#matkhau2').css("border","1px solid #cecece");
                $('#passs').html("<img src='../../Images/icon_active.png' height='18' valign='midle' /> ").css("display","inline");
            }
        
        });
        $('input#sodienthoai').change(function(){
            t=/^\d{10}$/
            var v=$(this).val();
            if(t.test(v)==false){
                $(this).css("border","1px solid #f00");
                $(this).focus();
            } else{
                $(this).css("border","1px solid #cecece");
            }
        });
        $('input#email').change(function(){
            t = /^\w+@\w+(\.\w{2,3})+$/
            var v=$(this).val();
            if(t.test(v)==false){
                $(this).css("border","1px solid #f00");
                $(this).focus();
            } else{
                $(this).css("border","1px solid #cecece");
            }
        });
        function checkvalidate(){
            var check=true;
            $('input.validate').each(function(){
                var txt=$(this).val();
                if(txt.length<6){
                    $(this).css("border","1px solid #f00");
                    check=check&&false;
                } else{
                    $(this).css("border","1px solid #cecece");
                    check=check&&true;
                }
            });
            return check;
        }
        function submit(){
            check=checkvalidate();
            if(check==true){
                $('#create').submit();
            }
            return false;
        }
<?php
if (!empty($kq)) {
    if ($kq == true) {
        ?>
                    $(".ui-corner-all").addClass("ui-state-highlight");
                    $(".ui-corner-all p strong").html("Sửa thành công !");
                    $(".ui-corner-all").fadeTo("slow", 1);
                    //setTimeout("$('.ui-corner-all').slideUp('slow');","2000");
                    setTimeout("window.location=window.location;","2000");
    <?php } else { ?>
                $(".ui-corner-all").addClass("ui-state-error");
                $(".ui-corner-all p strong").html("Sửa thất bại !");
                $(".ui-corner-all").fadeTo("slow", 1);
                setTimeout("$('.ui-corner-all').slideUp('slow');","2000");
    <?php }
} ?>    
    
    </script>